import java.io.BufferedReader;
import java.io.FileReader;
import java.io.IOException;
import java.util.ArrayList;
import java.util.ListIterator;
import java.util.StringTokenizer;


public class QueryMatch {

	/*
	 * this class should have as its values the 
	 * 4 passed in rstw or the matching ranges
	 * and the file name and that is it
	 */
	public QueryMatch(){
		
	}
	
	public static double exactMatch(ArrayList<Tuple> arraylist, int r, int s, int t, int u, boolean verbose) throws IOException{

		int matching= 0;
			    
	    // now the actual data is in the memory, just go through all the 
	    // numbers and see if they are 
	    ListIterator<Tuple> iter= arraylist.listIterator();
    	//if (verbose) {
    	//	System.out.println("now matching the actual tuples each DOT or . represent matched");}
	    
    	while(iter.hasNext()){
	    	Tuple current= iter.next();
	    	
	    	int a1 = current.getA1();
	    	int a2 = current.getA2();
	    
	    	if ( r <= a1 && s >= a1 && t <= a2 && u >= a2 ){
	    		matching++;
	    		//if (verbose) { System.out.print('.');}    	
	    	}
	    }
	    
	    if (verbose) { System.out.println("\nfinished exact matching");}
		return matching;
	}

}
